package com.health.db.service.sm.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.health.db.dao.sm.IRedisSentinelTemplateDao;
import com.health.db.model.RedisSentinelTemplate;
import com.health.db.service.sm.IRedisSentinelTemplateService;

public class RedisSentinelTemplateServiceImpl implements IRedisSentinelTemplateService{
 
	IRedisSentinelTemplateDao  redisSentinelTemplateDao;
	
	
	public List<Map<String, Object>> getRedisSentinelTemplate(String bigGroups) {
	 
		
		List<Map<String, Object>>  vList = new ArrayList<Map<String,Object>>();
		 
	 
		List<RedisSentinelTemplate> redisSentinelTemplateList= null;
				  
		redisSentinelTemplateList=redisSentinelTemplateDao.getRedisSentinelTemplate(bigGroups);
		 
	
		for(RedisSentinelTemplate rst:redisSentinelTemplateList)
		{
			Map<String ,Object> e= new HashMap<String,Object>();
			
			e.put("TEMPLATE_CODE", rst.getTemplateCode());
			e.put("TEMPLATE_NAME", rst.getTemplateName());
			e.put("BIG_GROUP", rst.getBigGroup());
			e.put("MSG_TYPE", rst.getMsgType());
			e.put("REGEX", rst.getRegex());
			e.put("MASTER_NAME", rst.getMasterName());
			e.put("SENTINEL_PROPERTIES", rst.getSentinelProperties());
			e.put("POOL_PROPERTIES", rst.getPoolProperties());
 
			
			
			vList.add(e);
		}
		
		
		
		
		
		
		
	
		return vList;
		
		 
	}

	public List<Map<String, Object>> getRedisTemplate() {
		//SqlSession sqlSession = factory.openSession();
		List<Map<String, Object>>  vList = new ArrayList<Map<String,Object>>();
		 
		 
		List<RedisSentinelTemplate> redisSentinelTemplateList= null;
 
		  
				  
		redisSentinelTemplateList=redisSentinelTemplateDao.getRedisTemplate();
		 
		  
		Map<String ,Object> e= new HashMap<String,Object>();
		//e.put(bigGroups, redisSentinelTemplateList.get(0));
		
		//ceshi
		e.put("TEMPLATE_CODE", "1");
		e.put("TEMPLATE_NAME", "1");
		e.put("BIG_GROUP","1");
		e.put("MSG_TYPE","1");
		e.put("REGEX","1");
		e.put("MASTER_NAME", "1");
		e.put("SENTINEL_PROPERTIES", "host=127.0.0.1,port=6379");
		e.put("POOL_PROPERTIES", "maxTotal=100minIdle=10maxIdle=10maxWaitMillis=10000testOnBorrow=truetestOnReturn=truetestWhileIdle=true");

		vList.add(e);
		
		return vList;
	}

	public IRedisSentinelTemplateDao getRedisSentinelTemplateDao() {
		return redisSentinelTemplateDao;
	}

	public void setRedisSentinelTemplateDao(
			IRedisSentinelTemplateDao redisSentinelTemplateDao) {
		this.redisSentinelTemplateDao = redisSentinelTemplateDao;
	}

 

 
}
